Skip to content

[test optimization] Fix bug that makes some tags not visible on mocha tests with hooks#7912

Merged
juan-fernandez merged 11 commits intomasterfrom
sebas_conde/tags_bug_fixing_mocha
Apr 7, 2026
Merged

[test optimization] Fix bug that makes some tags not visible on mocha tests with hooks#7912
juan-fernandez merged 11 commits intomasterfrom
sebas_conde/tags_bug_fixing_mocha

Conversation

@cbasitodx
Copy link
Copy Markdown
Contributor

@cbasitodx cbasitodx commented Apr 1, 2026

What does this PR do?

Fixes a bug where mocha tests with afterEach hooks do not report certain tags. In particular, the following tags (grouped by functionality) are now being reported in mocha tests with afterEach hooks:

  • (ATR, ATF, EFD) TEST_HAS_FAILED_ALL_RETRIES
  • (ATF) TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED
  • (ATF) TEST_IS_RETRY
  • (ATR) TEST_RETRY_REASON_TYPES

Motivation

Mocha tests with afterEach hooks were not reporting certain tags. This was because they were being lost when calling the hook handler (getOnHookEndHandler), since the tags were being computed in the local scope of getOnTestEndHandler. Solution was to include them in the context ctx object, that is accesible from getOnHookEndHandler after leaving getOnTestEndHandler's scope.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Overall package size

Self size: 5.47 MB
Deduped: 6.32 MB
No deduping: 6.32 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 bot commented Apr 1, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 68.69% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 910b31b | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.24%. Comparing base (2bb443c) to head (3e63e99).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...ckages/datadog-instrumentations/src/mocha/utils.js 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7912      +/-   ##
==========================================
- Coverage   74.35%   74.24%   -0.12%     
==========================================
  Files         768      765       -3     
  Lines       35855    35784      -71     
==========================================
- Hits        26660    26567      -93     
- Misses       9195     9217      +22     
Flag Coverage Δ
aiguard-macos 39.42% <ø> (+0.08%) ⬆️
aiguard-ubuntu 39.54% <ø> (+0.09%) ⬆️
aiguard-windows 39.21% <ø> (+0.08%) ⬆️
apm-capabilities-tracing-macos 49.14% <ø> (+0.06%) ⬆️
apm-capabilities-tracing-ubuntu 49.10% <ø> (+0.10%) ⬆️
apm-capabilities-tracing-windows 48.91% <ø> (+0.05%) ⬆️
apm-integrations-child-process 38.74% <ø> (+0.08%) ⬆️
apm-integrations-couchbase-18 37.53% <ø> (+0.06%) ⬆️
apm-integrations-couchbase-eol 38.05% <ø> (+0.24%) ⬆️
apm-integrations-oracledb 38.01% <ø> (+0.20%) ⬆️
appsec-express 55.39% <ø> (+0.14%) ⬆️
appsec-fastify 51.72% <ø> (+0.13%) ⬆️
appsec-graphql 51.87% <ø> (+0.12%) ⬆️
appsec-kafka 44.50% <ø> (+0.11%) ⬆️
appsec-ldapjs 44.12% <ø> (+0.10%) ⬆️
appsec-lodash 43.71% <ø> (+0.09%) ⬆️
appsec-macos 58.24% <0.00%> (+0.13%) ⬆️
appsec-mongodb-core 48.90% <ø> (+0.12%) ⬆️
appsec-mongoose 49.56% <ø> (+0.12%) ⬆️
appsec-mysql 50.98% <ø> (+0.12%) ⬆️
appsec-node-serialize 43.30% <ø> (+0.09%) ⬆️
appsec-passport 47.76% <ø> (+0.13%) ⬆️
appsec-postgres 50.71% <ø> (+0.13%) ⬆️
appsec-sourcing 42.55% <ø> (+0.09%) ⬆️
appsec-stripe 44.74% <ø> (+0.10%) ⬆️
appsec-template 43.46% <ø> (+0.09%) ⬆️
appsec-ubuntu 58.31% <0.00%> (+0.13%) ⬆️
appsec-windows 58.05% <0.00%> (+0.15%) ⬆️
instrumentations-instrumentation-bluebird 32.33% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-body-parser 40.64% <ø> (+0.09%) ⬆️
instrumentations-instrumentation-child_process 38.08% <ø> (+0.07%) ⬆️
instrumentations-instrumentation-cookie-parser 34.36% <ø> (+0.04%) ⬆️
instrumentations-instrumentation-express 34.68% <ø> (+0.04%) ⬆️
instrumentations-instrumentation-express-mongo-sanitize 34.49% <ø> (+0.04%) ⬆️
instrumentations-instrumentation-express-session 40.27% <ø> (+0.08%) ⬆️
instrumentations-instrumentation-fs 32.02% <ø> (+0.02%) ⬆️
instrumentations-instrumentation-generic-pool 29.42% <0.00%> (+0.20%) ⬆️
instrumentations-instrumentation-http 40.00% <ø> (+0.09%) ⬆️
instrumentations-instrumentation-knex 32.40% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-mongoose 33.52% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-multer 40.39% <ø> (+0.08%) ⬆️
instrumentations-instrumentation-mysql2 38.41% <ø> (+0.07%) ⬆️
instrumentations-instrumentation-passport 44.17% <ø> (+0.10%) ⬆️
instrumentations-instrumentation-passport-http 43.85% <ø> (+0.10%) ⬆️
instrumentations-instrumentation-passport-local 44.38% <ø> (+0.10%) ⬆️
instrumentations-instrumentation-pg 37.85% <ø> (+0.07%) ⬆️
instrumentations-instrumentation-promise 32.26% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-promise-js 32.27% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-q 32.31% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-url 32.23% <ø> (+0.03%) ⬆️
instrumentations-instrumentation-when 32.28% <ø> (+0.03%) ⬆️
llmobs-ai 41.61% <ø> (-0.86%) ⬇️
llmobs-anthropic 40.57% <ø> (+0.08%) ⬆️
llmobs-bedrock 39.33% <ø> (+0.07%) ⬆️
llmobs-google-genai 39.88% <ø> (+0.07%) ⬆️
llmobs-langchain 39.36% <ø> (-0.80%) ⬇️
llmobs-openai 44.09% <ø> (+0.10%) ⬆️
llmobs-vertex-ai 40.14% <ø> (+0.08%) ⬆️
platform-core 31.47% <ø> (ø)
platform-esbuild 34.42% <ø> (ø)
platform-instrumentations-misc 34.11% <ø> (-14.30%) ⬇️
platform-shimmer 37.56% <ø> (ø)
platform-unit-guardrails 32.89% <ø> (ø)
platform-webpack 19.96% <0.00%> (+<0.01%) ⬆️
plugins-azure-durable-functions 25.74% <ø> (ø)
plugins-azure-event-hubs 25.90% <ø> (ø)
plugins-azure-service-bus 25.26% <ø> (ø)
plugins-bullmq 43.62% <ø> (-0.88%) ⬇️
plugins-cassandra 37.89% <ø> (+0.07%) ⬆️
plugins-cookie 26.96% <ø> (ø)
plugins-cookie-parser 26.75% <ø> (ø)
plugins-crypto 26.73% <ø> (ø)
plugins-dd-trace-api 38.44% <ø> (+0.08%) ⬆️
plugins-express-mongo-sanitize 26.89% <ø> (ø)
plugins-express-session 26.70% <ø> (ø)
plugins-fastify 42.37% <ø> (+0.10%) ⬆️
plugins-fetch 38.52% <ø> (+0.07%) ⬆️
plugins-fs 38.76% <ø> (+0.08%) ⬆️
plugins-generic-pool 25.94% <ø> (ø)
plugins-google-cloud-pubsub 45.69% <ø> (+0.11%) ⬆️
plugins-grpc 41.02% <ø> (+0.09%) ⬆️
plugins-handlebars 26.94% <ø> (ø)
plugins-hapi 40.28% <ø> (+0.09%) ⬆️
plugins-hono 40.61% <ø> (+0.09%) ⬆️
plugins-ioredis 38.60% <ø> (+0.08%) ⬆️
plugins-knex 26.57% <ø> (ø)
plugins-langgraph 38.00% <ø> (-0.56%) ⬇️
plugins-ldapjs 24.43% <ø> (ø)
plugins-light-my-request 26.30% <ø> (ø)
plugins-limitd-client 32.61% <ø> (+0.03%) ⬆️
plugins-lodash 26.03% <ø> (ø)
plugins-mariadb 39.62% <ø> (+0.08%) ⬆️
plugins-memcached 38.31% <ø> (+0.08%) ⬆️
plugins-microgateway-core 39.35% <ø> (+0.08%) ⬆️
plugins-moleculer 40.64% <ø> (+0.09%) ⬆️
plugins-mongodb 39.28% <ø> (+0.08%) ⬆️
plugins-mongodb-core 39.12% <ø> (+0.08%) ⬆️
plugins-mongoose 38.93% <ø> (+0.07%) ⬆️
plugins-multer 26.70% <ø> (ø)
plugins-mysql 39.32% <ø> (+0.08%) ⬆️
plugins-mysql2 39.41% <ø> (+0.08%) ⬆️
plugins-node-serialize 27.00% <ø> (ø)
plugins-opensearch 37.75% <ø> (+0.07%) ⬆️
plugins-passport-http 26.76% <ø> (ø)
plugins-postgres 35.56% <0.00%> (+0.03%) ⬆️
plugins-process 26.73% <ø> (ø)
plugins-pug 26.96% <ø> (ø)
plugins-redis 39.05% <ø> (+0.08%) ⬆️
plugins-router 43.37% <ø> (+0.11%) ⬆️
plugins-sequelize 25.55% <ø> (ø)
plugins-test-and-upstream-amqp10 38.62% <ø> (+0.08%) ⬆️
plugins-test-and-upstream-amqplib 44.37% <ø> (+0.12%) ⬆️
plugins-test-and-upstream-apollo 39.24% <ø> (+0.07%) ⬆️
plugins-test-and-upstream-avsc 38.70% <ø> (+0.08%) ⬆️
plugins-test-and-upstream-bunyan 33.94% <ø> (+0.04%) ⬆️
plugins-test-and-upstream-connect 40.94% <ø> (+0.09%) ⬆️
plugins-test-and-upstream-graphql 40.28% <ø> (+0.09%) ⬆️
plugins-test-and-upstream-koa 40.53% <ø> (+0.09%) ⬆️
plugins-test-and-upstream-protobufjs 38.93% <ø> (+0.08%) ⬆️
plugins-test-and-upstream-rhea 44.40% <ø> (+0.12%) ⬆️
plugins-undici 39.24% <ø> (+0.07%) ⬆️
plugins-url 26.73% <ø> (ø)
plugins-valkey 38.31% <ø> (+0.07%) ⬆️
plugins-vm 26.73% <ø> (ø)
plugins-winston 34.13% <ø> (+0.04%) ⬆️
plugins-ws 42.13% <ø> (+0.10%) ⬆️
profiling-macos 40.66% <ø> (+0.09%) ⬆️
profiling-ubuntu 40.78% <ø> (+0.09%) ⬆️
profiling-windows 41.93% <ø> (-0.32%) ⬇️
serverless-azure-functions-client 25.62% <ø> (ø)
serverless-azure-functions-eventhubs 25.62% <ø> (ø)
serverless-azure-functions-servicebus 25.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.25%. Comparing base (a3baec5) to head (910b31b).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ckages/datadog-instrumentations/src/mocha/utils.js 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7912      +/-   ##
==========================================
- Coverage   74.26%   74.25%   -0.02%     
==========================================
  Files         769      769              
  Lines       36063    36068       +5     
==========================================
  Hits        26782    26782              
- Misses       9281     9286       +5     
Flag Coverage Δ
aiguard-macos 39.44% <ø> (-0.10%) ⬇️
aiguard-ubuntu 39.56% <ø> (-0.10%) ⬇️
aiguard-windows 39.23% <ø> (-0.10%) ⬇️
apm-capabilities-tracing-macos 49.55% <ø> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 49.47% <ø> (ø)
apm-capabilities-tracing-windows 49.34% <ø> (ø)
apm-integrations-child-process 38.77% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.52% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-eol 38.04% <ø> (-0.07%) ⬇️
apm-integrations-oracledb 37.87% <ø> (-0.10%) ⬇️
appsec-express 55.38% <ø> (-0.07%) ⬇️
appsec-fastify 51.71% <ø> (-0.07%) ⬇️
appsec-graphql 51.87% <ø> (-0.07%) ⬇️
appsec-kafka 44.49% <ø> (-0.09%) ⬇️
appsec-ldapjs 44.11% <ø> (-0.08%) ⬇️
appsec-lodash 43.71% <ø> (-0.08%) ⬇️
appsec-macos 58.09% <0.00%> (-0.09%) ⬇️
appsec-mongodb-core 48.89% <ø> (-0.08%) ⬇️
appsec-mongoose 49.54% <ø> (-0.09%) ⬇️
appsec-mysql 51.08% <ø> (-0.07%) ⬇️
appsec-node-serialize 43.29% <ø> (-0.08%) ⬇️
appsec-passport 47.76% <ø> (-0.09%) ⬇️
appsec-postgres 50.70% <ø> (-0.07%) ⬇️
appsec-sourcing 42.54% <ø> (-0.08%) ⬇️
appsec-stripe 44.73% <ø> (-0.09%) ⬇️
appsec-template 43.45% <ø> (-0.08%) ⬇️
appsec-ubuntu 58.18% <0.00%> (-0.09%) ⬇️
appsec-windows 57.91% <0.00%> (-0.09%) ⬇️
instrumentations-instrumentation-bluebird 32.33% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.63% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-child_process 38.07% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.36% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express 34.67% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.49% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-session 40.27% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-fs 32.01% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-generic-pool 29.41% <0.00%> (-0.04%) ⬇️
instrumentations-instrumentation-http 39.99% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.39% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.51% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.38% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-mysql2 38.40% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport 44.16% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 43.84% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.37% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.84% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.26% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise-js 32.26% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.23% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.28% <ø> (-0.11%) ⬇️
llmobs-ai 41.37% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.84% <ø> (-0.09%) ⬇️
llmobs-bedrock 39.32% <ø> (-0.08%) ⬇️
llmobs-google-genai 40.00% <ø> (+0.04%) ⬆️
llmobs-langchain 39.45% <ø> (-0.08%) ⬇️
llmobs-openai 44.12% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.13% <ø> (-0.09%) ⬇️
platform-core 31.47% <ø> (ø)
platform-esbuild 34.42% <ø> (ø)
platform-instrumentations-misc 34.11% <ø> (ø)
platform-shimmer 37.56% <ø> (ø)
platform-unit-guardrails 32.89% <ø> (ø)
platform-webpack 19.86% <0.00%> (-0.01%) ⬇️
plugins-azure-durable-functions 25.74% <ø> (ø)
plugins-azure-event-hubs 25.90% <ø> (ø)
plugins-azure-service-bus 25.26% <ø> (ø)
plugins-bullmq 43.61% <ø> (+0.03%) ⬆️
plugins-cassandra 38.02% <ø> (-0.10%) ⬇️
plugins-cookie 26.96% <ø> (ø)
plugins-cookie-parser 26.75% <ø> (ø)
plugins-crypto 26.73% <ø> (ø)
plugins-dd-trace-api 38.43% <ø> (-0.10%) ⬇️
plugins-express-mongo-sanitize 26.89% <ø> (ø)
plugins-express-session 26.70% <ø> (ø)
plugins-fastify 42.36% <ø> (-0.09%) ⬇️
plugins-fetch 38.51% <ø> (-0.10%) ⬇️
plugins-fs 38.75% <ø> (-0.10%) ⬇️
plugins-generic-pool 25.94% <ø> (ø)
plugins-google-cloud-pubsub 45.68% <ø> (-0.09%) ⬇️
plugins-grpc 41.01% <ø> (-0.09%) ⬇️
plugins-handlebars 26.94% <ø> (ø)
plugins-hapi 40.41% <ø> (+0.04%) ⬆️
plugins-hono 40.61% <ø> (-0.10%) ⬇️
plugins-ioredis 38.60% <ø> (-0.10%) ⬇️
plugins-knex 26.57% <ø> (ø)
plugins-langgraph 37.99% <ø> (-0.10%) ⬇️
plugins-ldapjs 24.43% <ø> (ø)
plugins-light-my-request 26.30% <ø> (ø)
plugins-limitd-client 32.61% <ø> (-0.10%) ⬇️
plugins-lodash 26.03% <ø> (ø)
plugins-mariadb 39.61% <ø> (-0.15%) ⬇️
plugins-memcached 38.34% <ø> (-0.10%) ⬇️
plugins-microgateway-core 39.34% <ø> (-0.17%) ⬇️
plugins-moleculer 40.63% <ø> (-0.09%) ⬇️
plugins-mongodb 39.27% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.12% <ø> (-0.13%) ⬇️
plugins-mongoose 38.92% <ø> (-0.10%) ⬇️
plugins-multer 26.70% <ø> (ø)
plugins-mysql 39.45% <ø> (-0.10%) ⬇️
plugins-mysql2 39.41% <ø> (-0.10%) ⬇️
plugins-node-serialize 27.00% <ø> (ø)
plugins-opensearch 37.74% <ø> (-0.10%) ⬇️
plugins-passport-http 26.76% <ø> (ø)
plugins-postgres 35.66% <0.00%> (+<0.01%) ⬆️
plugins-process 26.73% <ø> (ø)
plugins-pug 26.96% <ø> (ø)
plugins-redis 39.04% <ø> (-0.10%) ⬇️
plugins-router 43.36% <ø> (-0.10%) ⬇️
plugins-sequelize 25.55% <ø> (ø)
plugins-test-and-upstream-amqp10 38.62% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-amqplib 44.37% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.24% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.69% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-bunyan 33.94% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-connect 40.93% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.28% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.52% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 38.92% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 44.37% <ø> (-0.10%) ⬇️
plugins-undici 39.36% <ø> (-0.09%) ⬇️
plugins-url 26.73% <ø> (ø)
plugins-valkey 38.30% <ø> (-0.10%) ⬇️
plugins-vm 26.73% <ø> (ø)
plugins-winston 34.26% <ø> (-0.10%) ⬇️
plugins-ws 42.12% <ø> (-0.10%) ⬇️
profiling-macos 40.65% <ø> (-0.10%) ⬇️
profiling-ubuntu 40.78% <ø> (-0.10%) ⬇️
profiling-windows 42.30% <ø> (+0.32%) ⬆️
serverless-azure-functions-client 25.62% <ø> (ø)
serverless-azure-functions-eventhubs 25.62% <ø> (ø)
serverless-azure-functions-servicebus 25.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Apr 6, 2026

Benchmarks

Benchmark execution time: 2026-04-07 18:20:30

Comparing candidate commit 910b31b in PR branch sebas_conde/tags_bug_fixing_mocha with baseline commit a3baec5 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 228 metrics, 32 unstable metrics.

@cbasitodx cbasitodx marked this pull request as ready for review April 6, 2026 10:54
@cbasitodx cbasitodx requested a review from a team as a code owner April 6, 2026 10:54
Copy link
Copy Markdown
Collaborator

@juan-fernandez juan-fernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job! A small comment about readability

@juan-fernandez
Copy link
Copy Markdown
Collaborator

E2E Test Report: SUCCESS ✅

Tested by: Shepherd Agent (autonomous QA for Datadog Test Optimization)

Test Environment

  • Method: Local testing with express playground (Mocha ~1249 tests)
  • Revision: 4856e15
  • Branch: sebas_conde/tags_bug_fixing_mocha
  • dd-trace-js version: 6.0.0-pre (injected from PR branch)
  • Node.js: v24.14.0, Mocha 10.8.2, macOS arm64

Results

Created a dedicated mocha test file with afterEach hooks (one always-passing test, one always-failing test) and ran it against three scenarios that exercise the affected tag paths:

Scenario Tests Generated Key Tags Verified Status
EFD (Early Flake Detection) 22 (2 original + 20 retries) test.is_new, test.is_retry, test.retry_reason=early_flake_detection, test.has_failed_all_retries
ATR (Auto Test Retries) 7 (2 original + 5 retries on failure) test.is_retry, test.retry_reason=auto_test_retry, test.has_failed_all_retries
ATF (Attempt-to-Fix) 22 (2 original + 20 retries) test.is_retry, test.retry_reason=attempt_to_fix, test.test_management.attempt_to_fix_passed, test.has_failed_all_retries, test.test_management.is_attempt_to_fix

Tag Verification Detail (ATF — most comprehensive)

Tag Test Value Correct?
test.test_management.attempt_to_fix_passed should always pass true
test.test_management.attempt_to_fix_passed should always fail false
test.has_failed_all_retries should always fail true
test.is_retry all retry spans true (20 spans)
test.retry_reason all retry spans attempt_to_fix (20 spans)
test.test_management.is_attempt_to_fix all test spans true (22 spans)

Test Methodology

  1. Created a mocha test file with an afterEach hook containing one passing and one failing test — the exact pattern that triggered the bug
  2. Ran against a local mock backend (mockdog) with three scenarios: EFD, ATR, and ATF
  3. Injected dd-trace-js from PR branch via --dep ddtracejs=sebas_conde/tags_bug_fixing_mocha
  4. Verified all four tags mentioned in the PR (TEST_HAS_FAILED_ALL_RETRIES, TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, TEST_IS_RETRY, TEST_RETRY_REASON_TYPES) are correctly present on mocha tests with afterEach hooks
  5. Confirmed tags are assigned to the correct tests (e.g., attempt_to_fix_passed=true on passing test, has_failed_all_retries=true on failing test)

This E2E test was performed by Shepherd — autonomous QA agent for Datadog Test Optimization

@juan-fernandez juan-fernandez merged commit 5e5ba43 into master Apr 7, 2026
946 of 949 checks passed
@juan-fernandez juan-fernandez deleted the sebas_conde/tags_bug_fixing_mocha branch April 7, 2026 18:36
dd-octo-sts bot pushed a commit that referenced this pull request Apr 8, 2026
@dd-octo-sts dd-octo-sts bot mentioned this pull request Apr 8, 2026
sabrenner pushed a commit that referenced this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants